// src/entities/server.entity.ts
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
import { ServerMetric } from './server-metric.entity';
import { Alert } from './alert.entity';

@Entity('servers')
export class Server {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 50, unique: true })
  serverName: string;

  @Column({ length: 15, nullable: true })
  ipAddress: string;

  @Column({ length: 50, nullable: true })
  location: string;

  @Column({ type: 'enum', enum: ['online', 'offline'], default: 'online' })
  status: string;

  @OneToMany(() => ServerMetric, (metric) => metric.server)
  metrics: ServerMetric[];

  @OneToMany(() => Alert, (alert) => alert.server)
  alerts: Alert[];
}
